<script type="text/javascript">
var deletePath = "<?php echo CController::createUrl('gallery/deletephoto')?>";
function removePhoto(obj,id){
	var r1=confirm('你确定要删除这个图片？');
	if(r1==true){
			$(obj).parent().parent().remove();
			window.path1=deletePath+"/id/"+id;
			$.ajax({
				url:deletePath+"/id/"+id
			});
	}
}
</script>

<body>

<!-- Start of first page -->
<div data-role="page" id="foo">
	<div data-role="header" data-theme="b">
		<h1>
			<?php echo $gallery->title?>
		</h1>
		<?php echo CHtml::link("列表",array("gallery/index"),array("data-role"=>"button","data-icon"=>"back",'rel'=>'external'))?>
		<?php echo CHtml::link("用户",array("user/index"),array("data-role"=>"button","data-icon"=>"star"))?>
	</div>
	<div class="ui-body ui-body-e">
			<?php if($uploaded!=0){echo "<p><span style='color: green'>Note:".$uploaded."张图片上传成功！</span></p>";	}?>
			<?php if(!empty($message)){
				foreach ($message as $error) {echo "<p><span style='color: #c00'>Error:".$error."</span></p>";}}?>
	</div>
	<div data-role="controlgroup" data-type="horizontal">
		<a href="#add" data-transition="slideup" data-role='button' data-theme='b' data-icon='plus' />上传</a>
		<a href="#edit" data-transition="slideup" data-role='button' data-theme='b' data-icon='gear'  />编辑</a>
		<a href="#slide" data-transition="pop" data-rel="dialog" data-role='button' data-theme='b' data-icon='grid'/>展示</a>
	</div>
	<div data-role="content">
	<?php foreach($photos as $photo):?>
		<div class='gallery'>
			<?php $imageHtml= CHtml::image(Yii::app()->request->baseUrl."/images/gallery/{$photo->member_gallery_id}_{$photo->id}.png"); 
			echo CHtml::link($imageHtml,array("gallery/photo","id"=>$photo->id),array("data-transition"=>"pop","data-rel"=>"dialog"));
			?>
			<div data-role="controlgroup"  data-type="horizontal">
				<a href="#" data-role="button" data-icon="delete" data-iconpos="notext" onclick='removePhoto(this,<?php echo $photo->id?>)'>Delete</a>
			</div>	
		</div>
	<?php endforeach;?>
	</div>
		
	<?php $this->renderPartial("//site/footer")?>
	<!-- footer -->
		
</div>

<div data-role="page" id="add">
	<div data-role="header" data-theme="b">
		<h1>
			上传图片
		</h1>
		<a href="#foo" data-transition="slidedown" data-icon="back">取消</a>
		<?php echo CHtml::link("用户",array("user/index"),array("data-role"=>"button","data-icon"=>"star"))?>
	</div>
	
	<div data-role="collapsible" data-collapsed='false'style="width: 98%; border-bottom: 1px dashed #b7b7b7">
		<h3>注意</h3>
		<ul>
			<li>图片上传支持格式：jpg, gif, png</li>
			<li>剩余空间：<?php echo $maxsize-count($photos)?></li>
		</ul>
	</div>	
	<?php echo CHtml::form('','post',array('enctype'=>'multipart/form-data',"data-ajax"=>"false","id"=>"photoForm")); ?>
	<div data-role="fieldcontain" style="margin-left: 20px;">
		<?php if(count($photos) <$maxsize):?>
		<input type='file'class="ui-input-text ui-body-null ui-corner-all ui-shadow-inset ui-body-c"name="image[]"> <br />	
		<?php endif?>
		<?php if(count($photos) <$maxsize-1):?>
		<input type='file'class="ui-input-text ui-body-null ui-corner-all ui-shadow-inset ui-body-c"name="image[]"> <br />
		<?php endif?>
	</div>
	<div data-role="controlgroup" data-type="horizontal"style="margin-left: 20px;">
		<input type='submit' data-theme='b' value='上传' data-inline='true' />
	</div>
	<?php echo CHtml::endForm(); ?>
			
	<?php $this->renderPartial("//site/footer")?>
	<!-- footer -->
		
</div>

<div data-role="page" id="edit">
	<div data-role="header" data-theme="b">
		<h1>
			图片库编辑
		</h1>
		<a href="#foo" data-transition="slidedown" data-icon="back">取消</a>
		<?php echo CHtml::link("用户",array("user/index"),array("data-role"=>"button","data-icon"=>"star"))?>
	</div>
	
	<div data-role="content">
		<div style="margin:5px 5px 5px 5px;">
		<?php echo CHtml::form('','post',array("onsubmit"=>"return checkPost();","data-ajax"=>"false","name"=>"addform")); ?>
				<table style="width:90%">
					<tr>
						<td width=80px>标题：</td>
						<td><input type="text" id='posttitle' name="MemberGallery[title]" value="<?php echo $gallery->title?>" />
						</td>
					</tr>
					<tr>
						<td>简介：</td>
						<td><textarea style='width: 95%; height: 100px;' name="MemberGallery[description]" id='postContent'><?php echo $gallery->description?></textarea>
						</td>
					</tr>
					<tr>
						<td colspan='2'><input type='submit' data-theme='b' value='确定' data-icon='check'
							data-inline='true' />
						</td>
					</tr>
				</table>
		<?php echo CHtml::endForm(); ?>
		</div>
	</div>
	
	<?php $this->renderPartial("//site/footer")?>
	<!-- footer -->
		
</div>


<div data-role="page" id="slide">
	<div data-role="header" data-theme="b">
		<h1>
			图片
		</h1>
	</div>
	<div data-role="content" style="padding: 0 0 0 0;">
		<table width="100%">
		<tr>
			<td>
			<?php foreach($photos as $photo):?>
				<div class='photo_view'><?php echo CHtml::image(Yii::app()->request->baseUrl."/images/gallery/{$photo->member_gallery_id}_{$photo->id}.png"); ?></div>
			<?php endforeach;?>
			</td>
		</tr>
		</table>
	</div>
	<?php $this->renderPartial("//site/footer")?>
	<!-- footer -->	
</div>



</body>